package cloudspace.ui.applet.io;

import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.OutputStreamWriter;


public class CloudFileWriter extends OutputStreamWriter
{
    /**
     * Constructs a FileWriter object given a file name.
     * 
     * @param fileName
     *            String The system-dependent filename.
     * @throws IOException
     *             if the named file exists but is a directory rather than a
     *             regular file, does not exist but cannot be created, or cannot
     *             be opened for any other reason
     */
    public CloudFileWriter( String fileName ) throws IOException
    {
        super( new CloudFileOutputStream( fileName ) );
    }


    /**
     * Constructs a FileWriter object given a file name with a boolean
     * indicating whether or not to append the data written.
     * 
     * @param fileName
     *            String The system-dependent filename.
     * @param append
     *            boolean if <code>true</code>, then data will be written to the
     *            end of the file rather than the beginning.
     * @throws IOException
     *             if the named file exists but is a directory rather than a
     *             regular file, does not exist but cannot be created, or cannot
     *             be opened for any other reason
     */
    public CloudFileWriter( String fileName, boolean append )
        throws IOException
    {
        super( new CloudFileOutputStream( fileName, append ) );
    }


    /**
     * Constructs a FileWriter object given a File object.
     * 
     * @param file
     *            a File object to write to.
     * @throws IOException
     *             if the file exists but is a directory rather than a regular
     *             file, does not exist but cannot be created, or cannot be
     *             opened for any other reason
     */
    public CloudFileWriter( File file ) throws IOException
    {
        super( new CloudFileOutputStream( file ) );
    }


    /**
     * Constructs a FileWriter object given a File object. If the second
     * argument is <code>true</code>, then bytes will be written to the end of
     * the file rather than the beginning.
     * 
     * @param file
     *            a File object to write to
     * @param append
     *            if <code>true</code>, then bytes will be written to the end of
     *            the file rather than the beginning
     * @throws IOException
     *             if the file exists but is a directory rather than a regular
     *             file, does not exist but cannot be created, or cannot be
     *             opened for any other reason
     * @since 1.4
     */
    public CloudFileWriter( File file, boolean append ) throws IOException
    {
        super( new CloudFileOutputStream( file, append ) );
    }


    /**
     * Constructs a FileWriter object associated with a file descriptor.
     * 
     * @param fd
     *            FileDescriptor object to write to.
     */
    public CloudFileWriter( FileDescriptor fd )
    {
        super( null );
        throw new UnsupportedOperationException();
    }

}
